<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
   <style>
       div{
           height: 500px;
           width: 500px;
       }
   </style>
 </head>
<body>
             <button id="bn">开关</button>
           
               <div id="d"></div>

            <script>
                 $(function()
                 {
                    var k = 0;
                     $("#bn").bind("click",function()
                     {
                           if(k==0)
                           {
                               $("#d").css("backgroundColor","red");
                               k=1;
                           }
                           else if(k==1)
                           {
                            $("#d").css("backgroundColor","aliceblue");
                        k=0;
                           }
                     })
                 })
            </script>

</body>
</html>